package com.bdqn.dao;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import org.xml.sax.SAXException;

import java.io.File;
import java.util.Iterator;
import java.util.zip.DataFormatException;


public class showPhoneInfo {
    public static void main(String[] args) {
        showPhoneInfo();
    }

    public static void showPhoneInfo() {
        Document doc = null;
        try {
            SAXReader saxReader = new SAXReader();
            doc = saxReader.read(new File("ch02jd/src/ppp.xml"));
        } catch (DocumentException e) {
            e.printStackTrace();
        }
        Element root = doc.getRootElement();
        for (Iterator itid = root.elementIterator(); itid.hasNext(); ) {
            org.dom4j.Element id = (org.dom4j.Element) itid.next();
            //输出标签的name属性
            System.out.println("id:" + id.attributeValue("id"));
            //遍历type标签
            for (Iterator itBrand = root.elementIterator(); itBrand.hasNext(); ) {
                org.dom4j.Element brand = (org.dom4j.Element) itBrand.next();
                //输出标签的name属性
                System.out.println("姓名:" + brand.attributeValue("name"));
                //遍历type标签
                for (Iterator itcourse = root.elementIterator(); itcourse.hasNext(); ) {
                    org.dom4j.Element course = (org.dom4j.Element) itcourse.next();
                    //输出标签的name属性
                    System.out.println("课程:" + course.attributeValue("course"));
                    //遍历type标签
                }


                for (Iterator itscore = root.elementIterator(); itscore.hasNext(); ) {
                    org.dom4j.Element score = (org.dom4j.Element) itscore.next();
                    //输出标签的name属性
                    System.out.println("分数:" + score.attributeValue("score"));
                    //遍历type标签
                }

            }
        }
    }
}
